extends Node

class_name executeMove

onready var tween : Tween

signal finish

func execute(actor):
#	print(actor.sprite)
#	print(actor.temp_route)
#	print(actor.temp_autoRoute)
	var tween = Tween.new()
	actor.add_child(tween)	
	var totalList = actor.temp_route.addAll(actor.temp_autoRoute).arr
	for i in totalList.size()-1:
		var curPoint = totalList[i].toVector() * 32
		var nextPoint = totalList[i+1].toVector() *32
		if i == 0:
			tween.interpolate_property(actor, "position", curPoint, nextPoint, 0.2, 4, 0)
		else:
			tween.interpolate_property(actor, "position", curPoint, nextPoint, 0.1, 0, 0)
		tween.start()
		yield(tween, "tween_completed")
	emit_signal("finish")

#	tween.interpolate_property(actor, "position", position, position + dir * tile_size, 1.0/speed, Tween.TRANS_SINE, Tween.EASE_IN_OUT)
#	tween.start()
